import { urlApi } from "src/app/service/service.module";
import { Pipe, PipeTransform, Inject } from "@angular/core";
import { ImgStoreData } from "src/storage/.config/store.type";

@Pipe({
  name: "showImg"
})
export class ShowImgPipe implements PipeTransform {
  constructor(@Inject(urlApi) private url: string) {}

  transform(imgSrc: string, item: ImgStoreData["data"][0]): string {
    if (!item.config.storage) {
      return `${this.url}/${item.name}/${imgSrc}`;
    } else {
      return `${item.config.storage}/${item.name}/${imgSrc}`;
    }
  }
}
